<?php
     //用户信息控制器
     class UserInfoAction extends Action{
         public function index(){
             
         }
         
         //加载用户信息
         public function loadUserInfo(){
             
             $uId=1;
             $uInfo=getUser($uId);

             $data=getAddressSet($uId);
             
             if(count($data)>0){
                 //判断是否为默认选中状态
                 $this->assign("AddressList",$data);
             }
             
             $this->assign("userInfo",$uInfo[0])->display('UserInfo');
            //p($data);
         }
         
         //删除地址
         public function removeAds(){
            $InfoId= $_POST["InfoId"];
            
            $this->ajaxReturn(removeAddress($InfoId));
         }
         
         //添加、修改地址
         public function actionAddress(){
             $InfoId=$_POST["InfoId"];
             $UserId=$_POST['isUserId'];
             $State=$_POST['isState'];
             //p($State);
             $data['TakeName']=$_POST["TakeName"];
             $data['TakeAddress']=$_POST["TakeAddress"];
             $data['TakePhone']=$_POST["TakePhone"];
             $data['YnDefault']=$_POST["YnDefault"];
             
             if( $State=='1'){
                 
                 initValue($UserId);
             }
             
             
             if($InfoId!='null'){
               $data['InfoId']=$InfoId;
               $result=M('user_info')->save($data);
               $this->ajaxReturn($result);
             }else{
               $data['UserId']=$UserId;
               $result=M('user_info')->add($data);
               $this->ajaxReturn($result);
         }
             
             
             
         }
         
       
     }
?>